from constants import *
from town import *
from random import choice, random
from math import ceil

# DE_MOBS - follow by MOB_ code, number of
# DE_PAUSE - follow by max number of seconds, max respite
# DE_MESSAGE - follow by I_ code, string - Note this can be used as a hint that the player should detect traps! ("You hear a creak...") - Could be combined with DE_CHECKTRAPS also
# DE_NOFLEE
# DE_CLEARMOBS
# DE_GOLD - follow by min, max
# DE_GEMS - follow by min, max
# DE_WIN
# DE_QUIT
# DE_CHECKTRAPS
# DE_LOOT
# DE_GOLDCHEST - follow by locked chance, min, max
# DE_GEMSCHEST - follow by locked chance, min, max
# DE_PIT
# DE_EXPLOSIVERUNE
# DE_GASTRAP
# DE_SUMMONINGRUNE - follow by level
# DE_SPIKEDPIT
# DE_NOFLY
# DE_CANFLY
# DE_ALIGHT
# DE_DOOR
# DE_STAIRS

encounters_3 = []
encounters_3.append([[DE_MOBS,MOB_CENTIPEDE,3]])
encounters_3.append([[DE_MOBS,MOB_KOBOLD,3]])
encounters_3.append([[DE_MOBS,MOB_HARPY,2]])
encounters_3.append([[DE_MOBS,MOB_SNAKE,2]])
encounters_3.append([[DE_MOBS,MOB_ORC_WRETCH,2],[DE_MOBS,MOB_ORC_ROCK_THROWER,1]])
encounters_3.append([[DE_MOBS,MOB_ORC_WARRIOR,1]])
encounters_3.append([[DE_MOBS,MOB_COBRA,1]])
encounters_3.append([[DE_MOBS,MOB_GIANT_FIREFLY,1]])
encounters_3.append([[DE_MOBS,MOB_GIANT_WASP,1]])
encounters_3.append([[DE_MOBS,MOB_JELLY,1]])
encounters_3.append([[DE_MOBS,MOB_MILLIPEDE,1]])
encounters_3.append([[DE_MOBS,MOB_PYTHON,1]])
encounters_3.append([[DE_MOBS,MOB_GIANT_ANT,3]])
encounters_3.append([[DE_MOBS,MOB_BIG_KOBOLD,1]])
encounters_3.append([[DE_MOBS,MOB_POLTERGEIST,1]])

encounters_4 = []
encounters_4.append([[DE_MOBS,MOB_OOZE,1]])
encounters_4.append([[DE_MOBS,MOB_ORC_WARRIOR,1],[DE_MOBS,MOB_UGLY_THING,2]])
encounters_4.append([[DE_MOBS,MOB_ORC_WARRIOR,1],[DE_MOBS,MOB_BLAST_SPORE,1]])
encounters_4.append([[DE_MOBS,MOB_ORC_WARRIOR,2]])
encounters_4.append([[DE_MOBS,MOB_WOLF,2]])
encounters_4.append([[DE_MOBS,MOB_SKELETON,2]])
encounters_4.append([[DE_MOBS,MOB_GIANT_FIREFLY,1],[DE_MOBS,MOB_GIANT_WASP,1]])
encounters_4.append([[DE_MOBS,MOB_TROGLODYTE,2],[DE_MOBS,MOB_TROGLODYTE_ARCHER,1]])
encounters_4.append([[DE_MOBS,MOB_HARPY,3]])
encounters_4.append([[DE_MOBS,MOB_COBRA,1],[DE_MOBS,MOB_PYTHON,1]])
encounters_4.append([[DE_MOBS,MOB_ORC_WARRIOR,1],[DE_MOBS,MOB_ORC_ROCK_THROWER,2]])
encounters_4.append([[DE_MOBS,MOB_SPECTRE,1]])
encounters_4.append([[DE_MOBS,MOB_JELLY,2]])
encounters_4.append([[DE_MOBS,MOB_GOBLIN,3]])
encounters_4.append([[DE_MOBS,MOB_BEETLE,2]])
encounters_4.append([[DE_MOBS,MOB_BEAR,1]])
encounters_4.append([[DE_MOBS,MOB_POLTERGEIST,3]])

encounters_5 = []
encounters_5.append([[DE_MOBS,MOB_OOZE,2]])
encounters_5.append([[DE_MOBS,MOB_ORC_WARRIOR,2],[DE_MOBS,MOB_ORC_SLAVEMASTER,1]])
encounters_5.append([[DE_MOBS,MOB_TROGLODYTE,3],[DE_MOBS,MOB_TROGLODYTE_SHAMAN,1]])
encounters_5.append([[DE_MOBS,MOB_ORC_WRETCH,2],[DE_MOBS,MOB_ORC_WITH_MANCATCHER,1]])
encounters_5.append([[DE_MOBS,MOB_WOLF,3]])
encounters_5.append([[DE_MOBS,MOB_SKELETON,3],[DE_MOBS,MOB_SPECTRE,3]])
encounters_5.append([[DE_MOBS,MOB_JELLY,3]])
encounters_5.append([[DE_MOBS,MOB_TROGLODYTE,3],[DE_MOBS,MOB_TROGLODYTE_ARCHER,3]])
encounters_5.append([[DE_MOBS,MOB_NAGA_WARRIOR,1]])
encounters_5.append([[DE_MOBS,MOB_WIGHT,1]])
encounters_5.append([[DE_MOBS,MOB_TURTLOID,1]])
encounters_5.append([[DE_MOBS,MOB_OGRE,1]])
encounters_5.append([[DE_MOBS,MOB_FROZEN_SPIRIT,3]])
encounters_5.append([[DE_MOBS,MOB_TROLL,1]])
encounters_5.append([[DE_MOBS,MOB_THUG,3]])
encounters_5.append([[DE_MOBS,MOB_MINOTAUR,1]])
encounters_5.append([[DE_MOBS,MOB_SCORPION,3]])
encounters_5.append([[DE_MOBS,MOB_BIG_SPIDER,1]])
encounters_5.append([[DE_MOBS,MOB_SKELETON,2],[DE_MOBS,MOB_YOUNG_NECROMANCER,1]])

encounters_6 = []
encounters_6.append([[DE_MOBS,MOB_MANTICORE,1]])
encounters_6.append([[DE_MOBS,MOB_NAGA_WARRIOR,1],[DE_MOBS,MOB_NAGA_ARCHER,1]])
encounters_6.append([[DE_MOBS,MOB_ARTIFICER,1]])              
encounters_6.append([[DE_MOBS,MOB_BLACK_OGRE,1],[DE_MOBS,MOB_ORC_WARRIOR,2]])              
encounters_6.append([[DE_MOBS,MOB_DARK_DWARF,1]])              
encounters_6.append([[DE_MOBS,MOB_BASILISK,1]])              
encounters_6.append([[DE_MOBS,MOB_WIGHT,1],[DE_MOBS,MOB_SPECTRE,2],[DE_MOBS,MOB_SKELETON,1]])
encounters_6.append([[DE_MOBS,MOB_TROGLODYTE,3],[DE_MOBS,MOB_TROGLODYTE_ARCHER,2],[DE_MOBS,MOB_TROGLODYTE_PRIEST,1]])              
encounters_6.append([[DE_MOBS,MOB_ORC_WARRIOR,3],[DE_MOBS,MOB_ORC_ROCK_THROWER,2],[DE_MOBS,MOB_ORC_AGITATOR,1]])
encounters_6.append([[DE_MOBS,MOB_OGRE,2],[DE_MOBS,MOB_LEPRECHAUN,1]])
encounters_6.append([[DE_MOBS,MOB_OOZE,3]])
encounters_6.append([[DE_MOBS,MOB_SKELETON,1],[DE_MOBS,MOB_WRAITH,2]])  
encounters_6.append([[DE_MOBS,MOB_SKELETON,1],[DE_MOBS,MOB_MAGE,1]])
encounters_6.append([[DE_MOBS,MOB_BIG_SPIDER,2],[DE_MOBS,MOB_DARK_ELF_DRUID,1]])

encounters_7 = []
encounters_7.append([[DE_MOBS,MOB_SUMMONER,1]])
encounters_7.append([[DE_MOBS,MOB_TROGLODYTE_BEASTMASTER,1]])
encounters_7.append([[DE_MOBS,MOB_BAN_SIDHE,1]])
encounters_7.append([[DE_MOBS,MOB_HILL_GIANT,1]])
encounters_7.append([[DE_MOBS,MOB_STONE_GOLEM,1]])
encounters_7.append([[DE_MOBS,MOB_BLACK_KNIGHT,1],[DE_MOBS,MOB_MAGEBANE_EYE,1]])              
encounters_7.append([[DE_MOBS,MOB_MUTE_GHOST,1],[DE_MOBS,MOB_SPECTRE,1],[DE_MOBS,MOB_WIGHT,1]])              
encounters_7.append([[DE_MOBS,MOB_BURNING_GHOST,1],[DE_MOBS,MOB_SPECTRE,1],[DE_MOBS,MOB_WRAITH,1]])              
encounters_7.append([[DE_MOBS,MOB_WHITE_WOLF,3]])
encounters_7.append([[DE_MOBS,MOB_ORC_CHAMPION,2],[DE_MOBS,MOB_ORC_WARRIOR,3],])
encounters_7.append([[DE_MOBS,MOB_DARK_DWARF,1],[DE_MOBS,MOB_DARK_ELF_ARCHER,1]])              
encounters_7.append([[DE_MOBS,MOB_MAGE,1],[DE_MOBS,MOB_OGRE,2]])              
encounters_7.append([[DE_MOBS,MOB_DARK_PRIEST,1],[DE_MOBS,MOB_WIGHT,2]])              
encounters_7.append([[DE_MOBS,MOB_LIME_JELLY,2]])
encounters_7.append([[DE_MOBS,MOB_SHADOW,2]])
encounters_7.append([[DE_MOBS,MOB_ORC_WARRIOR,1],[DE_MOBS,MOB_WARLOCK,1]])
encounters_7.append([[DE_MOBS,MOB_SKELETON,3],[DE_MOBS,MOB_MUMMY,1],[DE_MOBS,MOB_POLTERGEIST,1]])              
encounters_7.append([[DE_MOBS,MOB_HELLHOUND,1]])
encounters_7.append([[DE_MOBS,MOB_BERSERKER,1]])

encounters_8 = []
encounters_8.append([[DE_MOBS,MOB_AIR_ELEMENTAL,1]]) 
encounters_8.append([[DE_MOBS,MOB_DARK_DWARF_LAIRD,1],[DE_MOBS,MOB_DARK_DWARF,1]]) 

rewards_3 = []
rewards_3.append([])
rewards_3.append([[DE_PAUSE,1,None],[DE_GOLD,1,10],[DE_PAUSE,1,None]])
rewards_3.append([[DE_PAUSE,1,None],[DE_GOLD,1,20],[DE_PAUSE,1,None]])
rewards_3.append([[DE_PAUSE,1,None],[DE_GOLD,1,30],[DE_PAUSE,1,None]])
rewards_3.append([[DE_PAUSE,1,None],[DE_GOLD,1,40],[DE_PAUSE,1,None]])
rewards_3.append([[DE_PAUSE,3,None]])
rewards_3.append([[DE_PAUSE,3,None]])
rewards_3.append([[DE_PAUSE,0.2,None],[DE_MESSAGE,None,'The floor creaks...'],[DE_CHECKTRAPS],[DE_PAUSE,3,None],[DE_PIT],[DE_PAUSE,2,None]])
rewards_3.append([[DE_PAUSE,0.2,None],[DE_MESSAGE,None,'You see something glowing on the floor...'],[DE_CHECKTRAPS],[DE_PAUSE,3,None],[DE_EXPLOSIVERUNE],[DE_PAUSE,2,None]])

rewards_4 = []
rewards_4.append([[DE_PAUSE,1,None],[DE_GOLD,5,10],[DE_PAUSE,1,None]])
rewards_4.append([[DE_PAUSE,1,None],[DE_GOLD,10,20],[DE_PAUSE,1,None]])
rewards_4.append([[DE_PAUSE,1,None],[DE_GOLD,20,35],[DE_PAUSE,1,None]])
rewards_4.append([[DE_PAUSE,1,None],[DE_GOLD,35,60],[DE_PAUSE,1,None]])
rewards_4.append([[DE_PAUSE,1,None],[DE_GOLDCHEST,50,30,70],[DE_PAUSE,1,None]]) # first parameter is locked chance
rewards_4.append([[DE_PAUSE,3,None]])
rewards_4.append([[DE_PAUSE,3,None]])
rewards_4.append([[DE_PAUSE,0.2,None],[DE_MESSAGE,None,'The floor creaks...'],[DE_CHECKTRAPS],[DE_PAUSE,3,None],[DE_PIT],[DE_PAUSE,2,None]])
rewards_4.append([[DE_PAUSE,0.2,None],[DE_MESSAGE,None,'You hear a quiet click...'],[DE_CHECKTRAPS],[DE_PAUSE,3,None],[DE_GASTRAP],[DE_PAUSE,2,None]])
rewards_4.append([[DE_PAUSE,0.2,None],[DE_MESSAGE,None,'You see something glowing on the floor...'],[DE_CHECKTRAPS],[DE_PAUSE,3,None],[DE_SUMMONINGRUNE,4],[DE_PAUSE,2,None]])

rewards_5 = []
rewards_5.append([[DE_PAUSE,1,None],[DE_GOLD,20,50],[DE_PAUSE,1,None]])
rewards_5.append([[DE_PAUSE,1,None],[DE_GOLD,20,50],[DE_PAUSE,1,None]])
rewards_5.append([[DE_PAUSE,1,None],[DE_GOLD,20,50],[DE_PAUSE,1,None]])
rewards_5.append([[DE_PAUSE,1,None],[DE_GEMS,40,80],[DE_PAUSE,1,None]])
rewards_5.append([[DE_PAUSE,1,None],[DE_GOLDCHEST,50,30,70],[DE_PAUSE,1,None]]) # first parameter is locked chance
rewards_5.append([[DE_PAUSE,2,None]])
rewards_5.append([[DE_PAUSE,0.2,None],[DE_MESSAGE,None,'You hear a quiet click...'],[DE_CHECKTRAPS],[DE_PAUSE,2,None],[DE_GASTRAP],[DE_PAUSE,2,None]])
rewards_5.append([[DE_PAUSE,0.2,None],[DE_MESSAGE,None,'The floor creaks...'],[DE_CHECKTRAPS],[DE_PAUSE,2,None],[DE_SPIKEDPIT],[DE_PAUSE,2,None]])
rewards_5.append([[DE_PAUSE,0.2,None],[DE_MESSAGE,None,'You see something glowing on the floor...'],[DE_CHECKTRAPS],[DE_PAUSE,2,None],[DE_SUMMONINGRUNE,5],[DE_PAUSE,2,None]])

rewards_6 = []
rewards_6.append([[DE_PAUSE,1,None],[DE_GOLD,30,70],[DE_PAUSE,1,None]])
rewards_6.append([[DE_PAUSE,1,None],[DE_GOLD,30,70],[DE_PAUSE,1,None]])
rewards_6.append([[DE_PAUSE,1,None],[DE_GEMS,40,80],[DE_PAUSE,1,None]])
rewards_6.append([[DE_PAUSE,1,None],[DE_GOLDCHEST,40,50,100],[DE_PAUSE,1,None]]) # first parameter is locked chance
rewards_6.append([[DE_PAUSE,1,None],[DE_GEMSCHEST,60,75,150],[DE_PAUSE,1,None]]) # first parameter is locked chance
rewards_6.append([[DE_PAUSE,1.5,None]])
rewards_6.append([[DE_PAUSE,0.2,None],[DE_MESSAGE,None,'You hear a quiet click...'],[DE_CHECKTRAPS],[DE_PAUSE,1.5,None],[DE_GASTRAP],[DE_PAUSE,2,None]])
rewards_6.append([[DE_PAUSE,0.2,None],[DE_MESSAGE,None,'The floor creaks...'],[DE_CHECKTRAPS],[DE_PAUSE,1.5,None],[DE_SPIKEDPIT],[DE_PAUSE,2,None]])
rewards_6.append([[DE_PAUSE,0.2,None],[DE_MESSAGE,None,'You see something glowing on the floor...'],[DE_CHECKTRAPS],[DE_PAUSE,1.5,None],[DE_SUMMONINGRUNE,6],[DE_PAUSE,2,None]])

rewards_7 = []
rewards_7.append([[DE_PAUSE,1,None],[DE_GOLDCHEST,40,50,100],[DE_PAUSE,1,None]]) # first parameter is locked chance
rewards_7.append([[DE_PAUSE,1,None],[DE_GEMSCHEST,60,75,150],[DE_PAUSE,1,None]]) # first parameter is locked chance

def get_reward(level):
    if level<3:
        return [DE_PAUSE,1,None]
    if level==3:
        return choice(rewards_3)
    if level==4:
        return choice(rewards_4)
    if level==5:
        return choice(rewards_5)
    if level==6:
        return choice(rewards_6)
    if level>=7:
        return choice(rewards_7)

def reward(level):
    s = []
    s.append([DE_PAUSE,9999,2])
    s = s + get_reward(level) # may actually be a summoning trap
    s.append([DE_PAUSE,9999,0.1])
    return s

def downstairs():
    s = []
    s.append([DE_PAUSE,9999,2])
    s.append([DE_STAIRS])
    s.append([DE_PAUSE,3,None])    
    return s

def door():
    s = []
    s.append([DE_PAUSE,9999,1.5])
    s.append([DE_DOOR])
    s.append([DE_PAUSE,2.5,None])
    return s    

def loot(level):
    s = []
    s.append([DE_PAUSE,9999,1.5])
    s.append([DE_LOOT,E_TREASURE_MAP])
    s.append([DE_PAUSE,1.5,None])
    return s

def win():
    s = []
    s.append([DE_PAUSE,9999,1])
    s.append([DE_WIN])
    s.append([DE_PAUSE,2,None])
    s.append([DE_QUIT])
    return s

def make_scenario_to_7():
    s = []
    s = s + downstairs()
    s = s + choice(encounters_4)
    s.append([DE_PAUSE,4,2])
    s = s + choice(encounters_4)
    s = s + reward(4)
    s = s + door()
    s = s + choice(encounters_5)
    s.append([DE_PAUSE,10,2])
    s = s + choice(encounters_5)
    s = s + reward(5)
    s = s + downstairs()
    s = s + choice(encounters_6)
    s.append([DE_PAUSE,10,2])
    s = s + choice(encounters_6)
    s = s + reward(6)
    s = s + door()
    s = s + choice(encounters_7)
    s.append([DE_PAUSE,10,2])
    s = s + choice(encounters_7)
    s = s + reward(7)
    s = s + loot()
    s = s + win()
    return s

def get_encounter(encounters,level):
    contents = []
    cumulative = []
    total = 0
    for encounter in encounters:
        if encounter[1] == level:
            contents.append(encounter[0])
            cumulative.append(total + encounter[2])
            total = total + encounter[2]
    rand = total * random()
    for i in range(len(contents)):
        if rand < cumulative[i]:
            return contents[i]

encounters = []
for encounter in encounters_3:
    encounters.append([encounter,3,1])
for encounter in encounters_4:
    encounters.append([encounter,4,1])
for encounter in encounters_5:
    encounters.append([encounter,5,1])
for encounter in encounters_6:
    encounters.append([encounter,6,1])
for encounter in encounters_7:
    encounters.append([encounter,7,1])

def make_scenario(from_level,to_level,encounters,length,initial_intensity,final_intensity,doors_and_stairs,rewards,start_message,last_level_message):
    # encounters is a set of triples - [MOB_ codes],level,relative probability
    # intensities scale from 1 to 10 (no actually can go higher)
    s = []
    if doors_and_stairs:
        s = s + downstairs()
    if start_message is not None:
        s.append([DE_MESSAGE,None,start_message])
    level = from_level
    remaining_length = length
    while 1:
        n_remaining_levels = (to_level - level + 1)
        n_encounters_this_level = int(ceil(float(remaining_length) / n_remaining_levels)) # could be variation in this...
        for i in range(n_encounters_this_level):
            intensity = initial_intensity + (final_intensity - initial_intensity) * (length - (remaining_length - i) - 0.5) / length
            s = s + get_encounter(encounters,level) # could be variation in mob level... or e.g. trickle in a large number of mobs of a lower type
            if i<(n_encounters_this_level-1):
                duration = 30.0 / (intensity + 2) # could be some randomness in this
                if random() > (intensity / 10.0) and doors_and_stairs:
                    s.append([DE_PAUSE,9999,duration/2.0])
                    s = s + door()
                else:    
                    s.append([DE_PAUSE,duration,duration/2.0])
        if rewards:
            s = s + reward(level)
        remaining_length = remaining_length - n_encounters_this_level
        if level < to_level:
            if doors_and_stairs:
                s = s + downstairs()
                if level==(to_level-1):
                    if last_level_message is not None:
                        s.append([DE_MESSAGE,None,last_level_message])
            else:    
                s.append([DE_PAUSE,9999,1])
            level = level + 1
        else:
            break
    if rewards:
        s = s + loot(level)
    s = s + win()
    return s

def make_test_scenario():
    return make_scenario(5,7,encounters,7,3,6,True,True,None,None)

def make_test2_scenario():
    return make_scenario(3,5,encounters,8,3,6,True,True,None,None)

orc_encounters = []
#
orc_encounters.append([[[DE_MOBS,MOB_ORC_WRETCH,4]],3,2])
orc_encounters.append([[[DE_MOBS,MOB_CENTIPEDE,3]],3,1])
orc_encounters.append([[[DE_MOBS,MOB_ORC_ROCK_THROWER,3]],3,2])
orc_encounters.append([[[DE_MOBS,MOB_SNAKE,3]],3,1])
orc_encounters.append([[[DE_MOBS,MOB_GIANT_ANT,2]],3,1])
orc_encounters.append([[[DE_MOBS,MOB_GIANT_WASP,1]],3,1])
orc_encounters.append([[[DE_MOBS,MOB_WOLF,1]],3,2])
orc_encounters.append([[[DE_MOBS,MOB_ORC_WARRIOR,1]],3,3])
orc_encounters.append([[[DE_MOBS,MOB_PYTHON,1]],3,1])
orc_encounters.append([[[DE_MOBS,MOB_MILLIPEDE,1]],3,1])
#
orc_encounters.append([[[DE_MOBS,MOB_ORC_WARRIOR,3]],4,2])
orc_encounters.append([[[DE_MOBS,MOB_ORC_WARRIOR,1],[DE_MOBS,MOB_ORC_ROCK_THROWER,3]],4,3])
orc_encounters.append([[[DE_MOBS,MOB_ORC_WARRIOR,1],[DE_MOBS,MOB_WOLF,1]],4,3])
orc_encounters.append([[[DE_MOBS,MOB_WOLF,3]],4,2])
orc_encounters.append([[[DE_MOBS,MOB_SCORPION,1]],4,1])
orc_encounters.append([[[DE_MOBS,MOB_GIANT_WASP,2]],4,1])
orc_encounters.append([[[DE_MOBS,MOB_MILLIPEDE,2]],4,1])
orc_encounters.append([[[DE_MOBS,MOB_BEETLE,1]],4,1])
orc_encounters.append([[[DE_MOBS,MOB_ORC_WRETCH,2],[DE_MOBS,MOB_ORC_SLAVEMASTER,1]],4,2])
#
orc_encounters.append([[[DE_MOBS,MOB_ORC_WARRIOR,3],[DE_MOBS,MOB_ORC_ROCK_THROWER,3]],5,3])
orc_encounters.append([[[DE_MOBS,MOB_ORC_WARRIOR,2],[DE_MOBS,MOB_WOLF,2]],5,2])
orc_encounters.append([[[DE_MOBS,MOB_ORC_WRETCH,3],[DE_MOBS,MOB_ORC_SLAVEMASTER,1],[DE_MOBS,MOB_ORC_ROCK_THROWER,2]],5,2])
orc_encounters.append([[[DE_MOBS,MOB_ORC_WARRIOR,2],[DE_MOBS,MOB_ORC_WITH_MANCATCHER,1]],5,2])
orc_encounters.append([[[DE_MOBS,MOB_ORC_WARRIOR,2],[DE_MOBS,MOB_ORC_AGITATOR,1]],5,2])
orc_encounters.append([[[DE_MOBS,MOB_ORC_WARRIOR,2],[DE_MOBS,MOB_WOLF,2]],5,2])
orc_encounters.append([[[DE_MOBS,MOB_ORC_WRETCH,2],[DE_MOBS,MOB_OGRE,1]],5,1])
orc_encounters.append([[[DE_MOBS,MOB_WHITE_WOLF,1]],5,1])
#
orc_encounters.append([[[DE_MOBS,MOB_ORC_WARRIOR,2],[DE_MOBS,MOB_ORC_CHAMPION,1]],6,3])
orc_encounters.append([[[DE_MOBS,MOB_ORC_WARRIOR,3],[DE_MOBS,MOB_WOLF,3]],6,2])
orc_encounters.append([[[DE_MOBS,MOB_ORC_WARRIOR,2],[DE_MOBS,MOB_ORC_WITH_MANCATCHER,1],[DE_MOBS,MOB_ORC_AGITATOR,1],[DE_MOBS,MOB_ORC_ROCK_THROWER,2]],6,2])
orc_encounters.append([[[DE_MOBS,MOB_WOLF,2],[DE_MOBS,MOB_WHITE_WOLF,1]],6,2])
orc_encounters.append([[[DE_MOBS,MOB_ORC_WARRIOR,2],[DE_MOBS,MOB_OGRE,1]],6,1])
orc_encounters.append([[[DE_MOBS,MOB_OGRE,2]],6,1])
orc_encounters.append([[[DE_MOBS,MOB_OGRE,1],[DE_MOBS,MOB_ORC_CHAMPION,1]],6,1])

def make_orc1_scenario():
    return make_scenario(3,6,orc_encounters,7,5,8,True,True,'You hear Orc-yells!',None)

def make_orc2_scenario():
    return make_scenario(4,6,orc_encounters,8,7,10,True,True,'You hear Orc-yells!',None)

crypt_encounters = []
#
crypt_encounters.append([[[DE_MOBS,MOB_POLTERGEIST,1]],3,3])
crypt_encounters.append([[[DE_MOBS,MOB_SKELETON,1]],3,3])
crypt_encounters.append([[[DE_MOBS,MOB_CENTIPEDE,3]],3,1])
crypt_encounters.append([[[DE_MOBS,MOB_SNAKE,3]],3,1])
crypt_encounters.append([[[DE_MOBS,MOB_COBRA,1]],3,1])
crypt_encounters.append([[[DE_MOBS,MOB_MILLIPEDE,1]],3,1])
#
crypt_encounters.append([[[DE_MOBS,MOB_SKELETON,1],[DE_MOBS,MOB_YOUNG_NECROMANCER,1]],4,1])
crypt_encounters.append([[[DE_MOBS,MOB_POLTERGEIST,2]],4,1])
crypt_encounters.append([[[DE_MOBS,MOB_SKELETON,3]],4,2])
crypt_encounters.append([[[DE_MOBS,MOB_FROZEN_SPIRIT,1]],4,2])
crypt_encounters.append([[[DE_MOBS,MOB_SCORPION,1]],4,1])
crypt_encounters.append([[[DE_MOBS,MOB_SPECTRE,1]],4,2])
crypt_encounters.append([[[DE_MOBS,MOB_COBRA,3]],4,1])
#
crypt_encounters.append([[[DE_MOBS,MOB_WRAITH,1]],5,2])
crypt_encounters.append([[[DE_MOBS,MOB_BIG_SPIDER,1]],5,1])
crypt_encounters.append([[[DE_MOBS,MOB_WIGHT,1]],5,2])
crypt_encounters.append([[[DE_MOBS,MOB_SKELETON,3],[DE_MOBS,MOB_POLTERGEIST,1],[DE_MOBS,MOB_YOUNG_NECROMANCER,1]],5,1])
crypt_encounters.append([[[DE_MOBS,MOB_FROZEN_SPIRIT,3]],5,2])
crypt_encounters.append([[[DE_MOBS,MOB_SCORPION,3]],5,1])
crypt_encounters.append([[[DE_MOBS,MOB_SPECTRE,3]],5,2])
crypt_encounters.append([[[DE_MOBS,MOB_SKELETON,2],[DE_MOBS,MOB_FROZEN_SPIRIT,1],[DE_MOBS,MOB_SPECTRE,1]],5,1])
#
crypt_encounters.append([[[DE_MOBS,MOB_SKELETON,2],[DE_MOBS,MOB_DARK_PRIEST,1]],6,1])
crypt_encounters.append([[[DE_MOBS,MOB_MUTE_GHOST,1]],6,2])
crypt_encounters.append([[[DE_MOBS,MOB_BURNING_GHOST,1]],6,2])
crypt_encounters.append([[[DE_MOBS,MOB_SHADOW,1]],6,1])
crypt_encounters.append([[[DE_MOBS,MOB_SKELETON,2],[DE_MOBS,MOB_MUMMY,1],[DE_MOBS,MOB_POLTERGEIST,1]],6,2])
crypt_encounters.append([[[DE_MOBS,MOB_WIGHT,2],[DE_MOBS,MOB_WRAITH,1]],6,1])
crypt_encounters.append([[[DE_MOBS,MOB_WIGHT,2],[DE_MOBS,MOB_SPECTRE,2]],6,1])
crypt_encounters.append([[[DE_MOBS,MOB_SKELETON,3],[DE_MOBS,MOB_FROZEN_SPIRIT,3]],6,1])
                       
def make_crypt1_scenario():
    return make_scenario(3,6,crypt_encounters,7,7,10,True,True,'This place has a spooky feeling...',None)

def make_crypt2_scenario():
    return make_scenario(4,6,crypt_encounters,9,9,12,True,True,'You hear a ghostly howl!',None)

swamp_encounters = []
#
swamp_encounters.append([[[DE_MOBS,MOB_CENTIPEDE,3]],3,1])
swamp_encounters.append([[[DE_MOBS,MOB_SNAKE,2]],3,1])
swamp_encounters.append([[[DE_MOBS,MOB_GIANT_ANT,2]],3,2])
swamp_encounters.append([[[DE_MOBS,MOB_HARPY,2]],3,1])
swamp_encounters.append([[[DE_MOBS,MOB_GIANT_FIREFLY,1]],3,3])
swamp_encounters.append([[[DE_MOBS,MOB_GIANT_WASP,1]],3,3])
swamp_encounters.append([[[DE_MOBS,MOB_COBRA,1]],3,1])
swamp_encounters.append([[[DE_MOBS,MOB_PYTHON,1]],3,1])
swamp_encounters.append([[[DE_MOBS,MOB_MILLIPEDE,1]],3,2])
#
swamp_encounters.append([[[DE_MOBS,MOB_GIANT_FIREFLY,1],[DE_MOBS,MOB_GIANT_WASP,1]],4,3])
swamp_encounters.append([[[DE_MOBS,MOB_COBRA,3]],4,1])
swamp_encounters.append([[[DE_MOBS,MOB_MILLIPEDE,2]],4,3])
swamp_encounters.append([[[DE_MOBS,MOB_SCORPION,1]],4,3])
swamp_encounters.append([[[DE_MOBS,MOB_SPECTRE,1]],4,1])
swamp_encounters.append([[[DE_MOBS,MOB_BEETLE,1]],4,1])
#
swamp_encounters.append([[[DE_MOBS,MOB_GIANT_FIREFLY,2],[DE_MOBS,MOB_GIANT_WASP,2]],5,2])
swamp_encounters.append([[[DE_MOBS,MOB_SCORPION,3]],5,2])
swamp_encounters.append([[[DE_MOBS,MOB_WRAITH,1]],5,1])
swamp_encounters.append([[[DE_MOBS,MOB_TURTLOID,1]],5,1])
swamp_encounters.append([[[DE_MOBS,MOB_SPECTRE,2]],5,1])
swamp_encounters.append([[[DE_MOBS,MOB_BEETLE,3]],5,2])
                       
def make_swamp_scenario():
    return make_scenario(3,5,swamp_encounters,8,8,16,False,False,'You hear the buzzing of insects...',None)

pit_encounters = []
#
pit_encounters.append([[[DE_MOBS,MOB_CENTIPEDE,3]],3,1])
pit_encounters.append([[[DE_MOBS,MOB_UGLY_THING,2]],3,1])
pit_encounters.append([[[DE_MOBS,MOB_GIANT_ANT,2]],3,1])
pit_encounters.append([[[DE_MOBS,MOB_TROGLODYTE,2]],3,1])
pit_encounters.append([[[DE_MOBS,MOB_BLAST_SPORE,1]],3,1])
pit_encounters.append([[[DE_MOBS,MOB_TROGLODYTE_ARCHER,1]],3,1])
pit_encounters.append([[[DE_MOBS,MOB_JELLY,1]],3,4])
pit_encounters.append([[[DE_MOBS,MOB_MILLIPEDE,1]],3,1])
#
pit_encounters.append([[[DE_MOBS,MOB_JELLY,3]],4,4])
pit_encounters.append([[[DE_MOBS,MOB_BEETLE,1]],4,1])
pit_encounters.append([[[DE_MOBS,MOB_OOZE,1]],4,4])
pit_encounters.append([[[DE_MOBS,MOB_TROGLODYTE,3],[DE_MOBS,MOB_TROGLODYTE_ARCHER,2]],4,1])
pit_encounters.append([[[DE_MOBS,MOB_BLAST_SPORE,1]],4,1])
pit_encounters.append([[[DE_MOBS,MOB_MILLIPEDE,3]],4,1])
#
pit_encounters.append([[[DE_MOBS,MOB_CLAY_GOLEM,1]],5,1])
pit_encounters.append([[[DE_MOBS,MOB_BEETLE,3]],5,1])
pit_encounters.append([[[DE_MOBS,MOB_OOZE,3]],5,4])
pit_encounters.append([[[DE_MOBS,MOB_LIME_JELLY,1]],5,4])
pit_encounters.append([[[DE_MOBS,MOB_SHADOW,2]],5,1])

def make_pit1_scenario():
    return make_scenario(3,5,pit_encounters,5,8,12,False,False,'Something icky oozes down the walls...',None)

def make_pit2_scenario():
    return make_scenario(4,5,pit_encounters,6,7,9,False,False,'Something icky oozes down the walls...',None)

trog_encounters = []
#
trog_encounters.append([[[DE_MOBS,MOB_SNAKE,3]],3,1])
trog_encounters.append([[[DE_MOBS,MOB_GIANT_ANT,2]],3,1])
trog_encounters.append([[[DE_MOBS,MOB_UGLY_THING,2]],3,1])
trog_encounters.append([[[DE_MOBS,MOB_TROGLODYTE,2]],3,4])
trog_encounters.append([[[DE_MOBS,MOB_COBRA,1]],3,1])
trog_encounters.append([[[DE_MOBS,MOB_PYTHON,1]],3,1])
trog_encounters.append([[[DE_MOBS,MOB_JELLY,1]],3,1])
#
trog_encounters.append([[[DE_MOBS,MOB_TROGLODYTE,3],[DE_MOBS,MOB_TROGLODYTE_ARCHER,2]],4,3])
trog_encounters.append([[[DE_MOBS,MOB_TROGLODYTE,2],[DE_MOBS,MOB_TROGLODYTE_SHAMAN,1]],4,3])
trog_encounters.append([[[DE_MOBS,MOB_COBRA,3]],4,1])
trog_encounters.append([[[DE_MOBS,MOB_OOZE,1]],4,1])
#
trog_encounters.append([[[DE_MOBS,MOB_TROGLODYTE,2],[DE_MOBS,MOB_TROGLODYTE_ARCHER,3]],5,1])
trog_encounters.append([[[DE_MOBS,MOB_TROGLODYTE,3],[DE_MOBS,MOB_TROGLODYTE_ARCHER,2],[DE_MOBS,MOB_TROGLODYTE_SHAMAN,1]],5,3])
trog_encounters.append([[[DE_MOBS,MOB_TROGLODYTE,2],[DE_MOBS,MOB_TROGLODYTE_PRIEST,1]],5,3])
trog_encounters.append([[[DE_MOBS,MOB_OOZE,3]],5,1])
#
trog_encounters.append([[[DE_MOBS,MOB_TROGLODYTE,3],[DE_MOBS,MOB_TROGLODYTE_BEASTMASTER,1],[DE_MOBS,MOB_TROGLODYTE_ARCHER,1],[DE_MOBS,MOB_TROGLODYTE_PRIEST,1]],6,1])

def make_trog1_scenario():
    return make_scenario(3,5,trog_encounters,5,4,8,True,True,'You hear troglodytes yammering!',None)

def make_trog2_scenario():
    return make_scenario(4,6,trog_encounters,5,4,8,True,True,'You hear troglodytes yammering!','This is the refuge of the troglodyte chief!')

adventures = {}
adventures["New random dungeon 3-5"] = make_test2_scenario
adventures["New random dungeon 5-7"] = make_test_scenario
adventures["Orc 1"] = make_orc1_scenario
adventures["Orc 2"] = make_orc2_scenario
adventures["Crypt 1"] = make_crypt1_scenario
adventures["Crypt 2"] = make_crypt2_scenario
adventures["Swamp"] = make_swamp_scenario
adventures["Pit 1"] = make_pit1_scenario
adventures["Pit 2"] = make_pit2_scenario
adventures["Troglodyte 1"] = make_trog1_scenario
adventures["Troglodyte 2"] = make_trog2_scenario

##def make_dragon_scenario():
##    s = []
##    s.append([DE_PAUSE,3,None])
##    s.append([DE_MOBS,MOB_CENTIPEDE,3])
##    s.append([DE_PAUSE,2,None])
##    s.append([DE_MOBS,MOB_CENTIPEDE,3])
##    s.append([DE_PAUSE,11,2])
##    s.append([DE_PAUSE,9999,1])
##    s.append([DE_GEMS,100,100])
##    s.append([DE_PAUSE,5,None])
##    s.append([DE_GOLD,10,10])
##    s.append([DE_PAUSE,5,None])
##    s.append([DE_CHECKTRAPS])
##    s.append([DE_PAUSE,1,None])
##    s.append([DE_PIT])
##    s.append([DE_PAUSE,5,None])
##    s.append([DE_CHECKTRAPS])
##    s.append([DE_PAUSE,1,None])
##    s.append([DE_EXPLOSIVERUNE])
##    s.append([DE_PAUSE,3,None])
##    s.append([DE_GOLDCHEST,50,10,10])
##    s.append([DE_PAUSE,3,None])
##    s.append([DE_GEMSCHEST,50,100,100])
##    s.append([DE_MOBS,MOB_ORC_WARRIOR,3]) 
##    s.append([DE_PAUSE,6,None])
##    s.append([DE_MOBS,MOB_TROGLODYTE_ARCHER,3]) 
##    s.append([DE_PAUSE,20,5])
##    s.append([DE_ALIGHT])
##    s.append([DE_MOBS,MOB_NAGA_WARRIOR,1])
##    s.append([DE_PAUSE,38,5])
##    s.append([DE_ALIGHT])
##    s.append([DE_NOFLY])
##    s.append([DE_MESSAGE,None,'You hear something heavy slithering closer...'])
##    s.append([DE_PAUSE,3,None])
##    s.append([DE_CLEARMOBS])
##    s.append([DE_PAUSE,3,None])
##    s.append([DE_NOFLEE])
##    s.append([DE_MOBS,MOB_YOUNG_RED_DRAGON,1]) 
##    s.append([DE_PAUSE,9999,1])
##    s.append([DE_GOLD,500,500])
##    s.append([DE_PAUSE,2,None])
##    s.append([DE_WIN])
##    s.append([DE_PAUSE,8,None])
##    s.append([DE_QUIT])
##    return s